package com.ngkj.zmfptback.sys.initData.servicie.write.impl;

import com.ngkj.zmfptback.sys.initData.bean.SysArea;
import com.ngkj.zmfptback.sys.initData.mapper.write.AreaWriteMapper;
import com.ngkj.zmfptback.sys.initData.servicie.write.AreaWriteService;
import com.ngkj.zmfptback.sys.initData.util.ChineseCharacterUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ChenHN
 * @since 2021/12/17 creation
 **/
@Service
public class AreaWriteServiceImpl implements AreaWriteService {

    @Resource
    private AreaWriteMapper writeMapper;

    @Override
    public void deleteArea(Long id) {
        writeMapper.deleteArea(id);
    }

    @Override
    public void addArea(SysArea sysArea) {
        String firstLetter = ChineseCharacterUtil.getFirstLetter(sysArea.getAreaName());
        sysArea.setFirstLetter(firstLetter);
        writeMapper.addArea(sysArea);
    }

    @Override
    public void editArea(SysArea sysArea) {
        String firstLetter = ChineseCharacterUtil.getFirstLetter(sysArea.getAreaName());
        sysArea.setFirstLetter(firstLetter);
        writeMapper.editArea(sysArea);
    }
}
